package com.micheal.mybatis.self;

/**
 * Created by micheal on 2018/4/10/0010.
 */
public class MicSqlSession {

    private MicConfiguration configuration;
    private MicExecutor executor;

    public MicSqlSession(MicConfiguration configuration, MicExecutor executor) {
        this.configuration = configuration;
        this.executor = executor;
    }

    /**
     * 获取Mapper
     * @param type
     * @param <T>
     * @return
     */
    public <T> T getMapper(Class<T> type){
        return configuration.getMapper(type, this);
    }

    /**
     * 执行sql
     * @param sql
     * @param parameter
     */
    public <T> T selectOne(String sql, String parameter) {
        return executor.query(sql, parameter);
    }
}
